#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <linux/input.h>

int key_fd;
#define  key_input  "/dev/input/event0"

int main (int argc,char ** argv )
{
    char i ;
    struct input_event  dev_key;
    unsigned char num[3]={1,1,1};
    unsigned char val;
    char * filename=NULL;

    key_fd =  open (key_input,O_RDONLY);
    if(key_fd<=0)
    {
        printf("can't open key");    
		return -1;
    }
     printf("key_fd %d\n",key_fd);    
     while(1)
     {
        if(read(key_fd,&dev_key,sizeof(dev_key))== sizeof(dev_key))
        {
            printf("type: 0x%x code: %d value: 0x%x\n", 
            dev_key.type,
            dev_key.code,  
            dev_key.value);
        }
     }
    return 0;
}



















